//
//  CYMeTVC.m
//  CreditAddressBook
//
//  Created by Lee on 15/7/26.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYMeTVC.h"
#import "CYUser.h"
#import "MJExtension.h"
#import "UIButton+WebCache.h"
#import "CYLoginHttpTool.h"
#import "DSNavigationBar.h"
#import "UMFeedback.h"
#import "CYJumpsTool.h"
#import "UMSocial.h"
#import "CYMyRelease.h"
#import "CYABTool.h"
#import "MBProgressHUD+MJ.h"
#import "CYHttpTool.h"
#import "CYMeHttpTool.h"
#import "CreditWebViewController.h"
#import "CYCopyViewController.h"
#import "CYRichViewController.h"
#import "CYNavigationVController.h"
#import "CYCloudSyn.h"
#import "UIViewController+Category.h"
#import "CYMessageViewController.h"
#import "CYJsonInfo.h"
#import "CYDiscoveryHttpTool.h"
#import "CYUserAccount.h"
#import "WebViewJavascriptBridge.h"
#import "CYPayViewController.h"
#import "CYAssetManagerVC.h"
#import "LEMDLib.h"
#import "UIImageView+WebCache.h"
#import "CYPersonalDetailsVController.h"
#import "CYTool.h"
#import "CYAssetDetailVC.h"
#import "CYBankcardBandTableViewController.h"
#import "CYGetdealCodeVC.h"
#import "CYPersonReleaseVC.h"
#import "UIInfomationView.h"
#import "CYGFBTool.h"
#import "UIAlertView+Block.h"
#import "CYDES3Util.h"
#import "TOWebViewController+LE.h"
#import "UIAlertView+Block.h"
#import "LEWebViewController+LE.h"
#import "LEUUID.h"
#import "DCPaymentView.h"
#import "CYbankcarddetailVC.h"
#import "JPUSHService.h"
#import "CYShopViewController.h"
#import "CYCardIDCheckVC.h"
#import "CYNewZFBVC.h"
#import "CYMEHelpWebVC.h"
#import "CYSettingTableVC.h"
#import "GCD.h"
#import "CYCreditNewLitmitVC.h"
#import "CYUserCarFindWebVC.h"
#import "CYCreditAddWebVC.h"
#import "CYMoneyAddWebVC.h"
#import "CYTixianVC.h"
#import "AppDelegate.h"
#import "CYShimingbangkaVC.h"
#import "CYShimingbangkaVC.h"
#import "CYShimingBangkaVCTableViewController.h"


#define CYHeadViewHeight 150.f
#define CYSectionTopToNaviBottomHeight (CYHeadViewHeight - 64.f)

@interface CYMeTVC ()<UMSocialUIDelegate,UITextFieldDelegate>


@property(nonatomic, strong) GCDTimer *GCDTimer;
@property (weak, nonatomic) IBOutlet UILabel *statusLab;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;//登陆名称
@property (weak, nonatomic) IBOutlet UILabel *mineDataLbel;//昵称
@property (weak, nonatomic) IBOutlet UIButton *personalBtn;//头像
@property (weak, nonatomic) IBOutlet UIButton *personalBtn1;//跳转或者登陆按钮

//----------------新版1视图控件-------------------//
@property (weak, nonatomic) IBOutlet UILabel *newyuelab;
@property (weak, nonatomic) IBOutlet UIButton *newtixianbtn;
@property (weak, nonatomic) IBOutlet UIButton *newchongzhibtn;
@property (weak, nonatomic) IBOutlet UIButton *newyinhangkabtn;
@property (weak, nonatomic) IBOutlet UIButton *newmingxibtn;
@property (weak, nonatomic) IBOutlet UIButton *newmessagebtn;
@property (weak, nonatomic) IBOutlet UIButton *newsetbtn;
@property (weak, nonatomic) IBOutlet UIButton *newcloudbtn;
@property (weak, nonatomic) IBOutlet UIButton *newhelpbtn;
@property (weak, nonatomic) IBOutlet UIButton *newsharebtn;


//----------------新版2视图控件-------------------//






//消息圆点Label
@property (weak, nonatomic) IBOutlet UILabel *newsLabel;


@property (weak, nonatomic) IBOutlet UILabel *jifenLabel;
@property (weak, nonatomic) IBOutlet UILabel *yeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *iconPhotoImageView;//相机小图标
@property (weak, nonatomic) IBOutlet UIView *headView;
@property (weak, nonatomic) IBOutlet UIButton *entershopbutton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageBottomConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageTopConstraint;

@property (weak, nonatomic) IBOutlet UIButton *bankcardbtn;
@property (weak, nonatomic) IBOutlet UIButton *dealcodebtn;
@property (weak, nonatomic) IBOutlet UIButton *assetbtn;
@property (weak, nonatomic) IBOutlet UILabel *bankcardlab;
@property (weak, nonatomic) IBOutlet UILabel *dealcodelab;
@property (weak, nonatomic) IBOutlet UIButton *chongzhibtn;
@property (weak, nonatomic) IBOutlet UIButton *tixianbtn;
@property (nonatomic, strong) UIWebView *backpay;
@property (strong, nonatomic) UIViewController *feedBack;
@property (nonatomic, strong) UITextField *dealcode;
@property (nonatomic, strong) UITextField *moneycount;
@property (strong, nonatomic) UIColor *naviColor;
@property (nonatomic, strong) NSString *status;
@property (weak, nonatomic) IBOutlet UIImageView *pointImagView;
@property (nonatomic, strong) NSString *ZFBStr;

@property (nonatomic, strong) NSString *zhifubaoSwitch;
@property (nonatomic, strong) NSString *zhibaobaoAccount;
@property (nonatomic, strong) NSString *zhifubaoName;
@property (nonatomic,strong)UIView *weixinbg;
@property (nonatomic, strong) UIView *weixinView;
@property (nonatomic, strong) UIButton *yzmBtn;

@property (nonatomic, strong) UITextField *accountTF;
@property (nonatomic, strong) UITextField *yzmTF;
@property (nonatomic, strong) NSNumber *account;


@end

@implementation CYMeTVC

- (UIViewController *)feedBack {
    if (!_feedBack) {
        _feedBack = [UMFeedback feedbackViewController];
        //通过swizzle viewDidAppear:实现
//        [CYJumpsTool exchangeMethodWhthClass:[_feedBack class] oldSEL:@selector(viewDidAppear:) newClass:[self class] newSEL:@selector(hook_viewWillAppear:)];
        //通过swizzle viewDidLoad实现
//        [CYTool swizzleWhthOriginalClass:[_feedBack class] originalSEL:@selector(viewDidLoad) swizzledClass:[self class] swizzledSEL:@selector(hook_viewDidLoad)];
        
        [CYTool addMethodWhthClass:[_feedBack class] selector:@selector(hook_viewDidLoad) targetClass:[self class] targetSelector:@selector(hook_viewDidLoad)];
        [_feedBack performSelector:@selector(hook_viewDidLoad)];
        _feedBack.hidesBottomBarWhenPushed = YES;
    }
    return _feedBack;
}

- (void)hook_viewDidLoad {
//    [super viewDidLoad];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CYScreeSize.width, 64)];
    view.backgroundColor = CYNaviThemeColor;
    [self.view addSubview:view];
     
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [JPUSHService setBadge:0];
    //            _pointImagView.hidden = YES;
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    if (IOS8) {
        [self.tableView sendSubviewToBack:self.headView];
    }
    //个人信息页面用户昵称跟改监听,和个人信息页面用户头像更改监听.
    [CYNotificationCenter addObserver:self selector:@selector(nickNameChange:) name:CYNickNameDidChangeNotification object:nil];
     //界面未出根据有无未读消息设置红点的显示
     UIApplication *application = [UIApplication sharedApplication];
     AppDelegate *appdelegate = (AppDelegate *)[application delegate];
     self.newsLabel.hidden = !appdelegate.isHaveJPNews;
     //消息小红点的监听
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateShow:) name:@"item" object:nil];
    _dealcodelab.text = @"--";
    _bankcardlab.text = @"--";
    [self loginStatus];
    self.tableView.showsVerticalScrollIndicator = NO;
    self.entershopbutton.backgroundColor = [UIColor clearColor];
    self.naviColor = CYNaviThemeColorWithAlpha(0);
    _pointImagView.layer.cornerRadius = 25.f;
    _pointImagView.layer.borderWidth = 0.2;
     
//    _pointImagView.hidden = YES;
    //积分
    [self requestNum1];
    //余额
     [self loadBalance];
    //通知
     [self setupNoti];
    
     [self setupZFBStatues];
}
- (void)updateShow:(NSNotification *) notifi {
     self.newsLabel.hidden = NO;
}

- (IBAction)newyinhangkaclick:(id)sender {
     
     CYUser *user = [CYLoginHttpTool userData].user;
     if (user) {
          if ([user.certificateExamineStatus  longLongValue] == 2 ) {
               if (_status.intValue != 1) {
                    CYBankcardBandTableViewController *bankcd = [CYBankcardBandTableViewController le_loadFromStoryBoard:[CYJumpsTool mainSB]];
                    bankcd.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:bankcd animated:YES];
                    return;
               }
               
               CYbankcarddetailVC *bacd = [[CYbankcarddetailVC alloc]init];
               bacd.hidesBottomBarWhenPushed = YES;
               [self.navigationController pushViewController:bacd animated:YES];
               
          }else{
               UIAlertView *txaler = [[UIAlertView alloc]initWithTitle:@"您需要进行绑卡!" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
               [txaler show];
               [txaler showAlertViewWithCompleteBlock:^(NSInteger buttonIndex) {
                    if (buttonIndex == 1) {
                         
                         CYCardIDCheckVC *cardcheck = [[CYCardIDCheckVC alloc]init];
                         cardcheck.hidesBottomBarWhenPushed = YES;
                         [self.navigationController pushViewController:cardcheck animated:YES];
                    }
               }];
          }
          
          // [txaler showAlertViewWithCompleteBlock:^(NSInteger buttonIndex)
          
     }else{
          [CYJumpsTool jumpToLogin:self];
     }

}

- (IBAction)newmessageclick:(id)sender {
     [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
     CYUser *user = [CYLoginHttpTool userData].user;
     _newsLabel.hidden = YES;
     UIApplication *application = [UIApplication sharedApplication];
     AppDelegate *appdelegate = (AppDelegate *)application.delegate;
     appdelegate.isHaveJPNews = NO;
     //改变tabBar
     //创建通知对象
     NSNotification *notification = [NSNotification notificationWithName:@"tabBar" object:nil];
     //发送通知
     NSNotificationCenter  * notificationCenter = [ NSNotificationCenter  defaultCenter];
     [notificationCenter postNotification:notification];
     if (user) {
          _newsLabel.hidden = YES;
          //改变tabBar
          //创建通知对象
          NSNotification *notification = [NSNotification notificationWithName:@"tabBar" object:nil];
          //发送通知
          NSNotificationCenter  *notificationCenter = [ NSNotificationCenter  defaultCenter];
          [notificationCenter postNotification:notification];
          _pointImagView.hidden = YES;
          
          CYMessageViewController *MessageVC = [[CYMessageViewController alloc]init];
          MessageVC.hidesBottomBarWhenPushed = YES;
          [self.navigationController pushViewController:MessageVC animated:YES];
     }
     else{
          [CYJumpsTool jumpToLogin:self];
     }

}

- (IBAction)newsetclick:(id)sender {
     
//     CYSettingTableVC *setvc = [[CYSettingTableVC alloc]init];
     
//     CYSettingTableVC  *setvc = [CYSettingTableVC le_loadFromStoryBoard:[CYJumpsTool mainSB]];
//     [self.navigationController pushViewController:setvc animated:YES];

     
}
- (IBAction)newcloudclick:(id)sender {
     CYUser *user = [CYLoginHttpTool userData].user;
     
     if (user) {
          //CYCopyViewController *copyVC = [[CYCopyViewController alloc]init];
          CYCloudSyn *copyVC = [CYCloudSyn le_loadFromStoryBoard:self.storyboard];
          copyVC.hidesBottomBarWhenPushed = YES;
          [self.navigationController pushViewController:copyVC animated:YES];
     } else {
          
          [CYJumpsTool jumpToLogin:self];
          
     }

}
- (IBAction)newhelpclick:(id)sender {
     //意见反馈
     //                [self.navigationController pushViewController:self.feedBack animated:YES];
     CYMEHelpWebVC *helpwebvc = [[CYMEHelpWebVC alloc]init];
     helpwebvc.hidesBottomBarWhenPushed = YES;
     [self.navigationController pushViewController:helpwebvc animated:YES];
     
     //                 CreditWebViewController *shopwebVC = [[CreditWebViewController alloc] initWithUrl:@"http://www.credit-manage.com/app/help/help.html"];
     //                 shopwebVC.hidesBottomBarWhenPushed = YES;
     //                 [self.navigationController pushViewController:shopwebVC animated:YES];
     
}
- (IBAction)newshareclick:(id)sender {
     
      [self share];
}


-(void)setupZFBStatues{
     [CYHttpTool postWithURL:[CYURL shared].getZhifubao params:@{} success:^(id json) {
          CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
          NSDictionary *dic = jsoninfo.data;
          _zhifubaoSwitch = [dic objectForKey:@"zhifubaoSwitch"];
          _zhifubaoName = [dic objectForKey:@"zhifubaoName"];
          _zhibaobaoAccount = [dic objectForKey:@"zhibaobaoAccount"];
          
     } failure:^(NSError *error) {
          
     }];
     
}


-(void)setdealcode{
    CYUser *user = [CYLoginHttpTool userData].user;
    [CYHttpTool postWithURL:[CYURL shared].getDealCodeStatus params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
        CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
        NSString  *type = jsonInfo.data;
        if (type.intValue == 1) {
            _dealcodelab.text = @"已设置";
        }else{
            _dealcodelab.text = @"未设置";
        }
    } failure:^(NSError *error) {
        CYLog(@"error = %@",error);
        _dealcodelab.text = @"--";
    }];
}

-(void)setbankcard{
    CYUser *user = [CYLoginHttpTool userData].user;
        [CYHttpTool postWithURL:[CYURL shared].getBandCardStatus params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
            CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
            if (jsoninfo.isSuccess) {
                NSDictionary *data = jsoninfo.data;
                NSString *str = [data valueForKey:@"cardNo"];
                _status = [data valueForKey:@"status"];
                 if (str.length >15) {
                      _bankcardlab.text = [NSString stringWithFormat:@"%@****%@", [str substringToIndex:4], [str substringFromIndex:15]];
                 }else {
                      _bankcardlab.text = str;

                 }
                if (!data) {
                    _bankcardlab.text = @"未绑定";
                }
            }
            
        } failure:^(NSError *error) {
            CYLog(@"error = %@",error);
            _bankcardlab.text = @"--";
        }];
    
}
-(void)requestNum1 {
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        [CYHttpTool postWithURL:[CYURL getAllPointByUserId] params:@{@"userId":user.userId} success:^(id json) {
            CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
            if (jsonInfo.isSuccess) {
                self.user_point= jsonInfo.message;
                self.jifenLabel.text = [NSString stringWithFormat:@"%@积分",jsonInfo.message];
            } else {
                self.jifenLabel.text = @"--";
            }
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getIndexes:) name:@"addCread" object:nil];
        } failure:^(NSError *error) {
            CYLog(@"更新用户审核资料服务器连接失败：%@", error);
        }];
    } else {
        self.jifenLabel.text = @"--";
    }
}

- (IBAction)bankcardclick:(id)sender {
     
}
- (IBAction)dealcodeclick:(id)sender {
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        CYGetdealCodeVC  *deal = [[CYGetdealCodeVC alloc]init];
        deal.hidesBottomBarWhenPushed = YES;
        if ([user.certificateExamineStatus  longLongValue] == 2 ) {
            [self.navigationController pushViewController:deal animated:YES];
        }else{
            UIAlertView *txaler = [[UIAlertView alloc]initWithTitle:@"您需要进行实名绑卡!" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
            [txaler show];
            [txaler showAlertViewWithCompleteBlock:^(NSInteger buttonIndex) {
                if (buttonIndex == 1) {

                     CYCardIDCheckVC *cardcheck = [[CYCardIDCheckVC alloc]init];
                     
                     cardcheck.hidesBottomBarWhenPushed = YES;
                     [self.navigationController pushViewController:cardcheck animated:YES];
                    
                }
            }];
        }
        
    }else{
        [CYJumpsTool jumpToLogin:self];
    }
}
- (IBAction)assetclick:(id)sender {
    
   
    
}
- (IBAction)chognzhiclick:(id)sender {
     
     
     
     
}
- (IBAction)tixianclick:(id)sender {
     
    
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
     //主要是[receiver resignFirstResponder]在哪调用就能把receiver对应的键盘往下收
     [_accountTF resignFirstResponder];
     [_yzmTF resignFirstResponder];
     
     return YES;
}


-(void)yzmClick{
     [self countdown];
     CYUser *user = [CYLoginHttpTool userData].user;
     //确认网络有连接后发送短信验证码
     [CYLoginHttpTool sendSMSWithPhone:user.phone success:^(id json) {
          //CYLog(@"sms: %@", json);
          CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
          if (jsonInfo.isSuccess) {
               [MBProgressHUD showSuccess:jsonInfo.message];
               
               
          }else {
               [MBProgressHUD showError:jsonInfo.message];
          }
     } failure:^(NSError *error) {
          [MBProgressHUD showError:CYServerConnectFailure];
          
     }];
     
}
/**
 *  倒计时
 */

- (void)countdown{
     self.GCDTimer = [[GCDTimer alloc] initInQueue:[GCDQueue mainQueue]];
     
     CYWeakObject(weakself, self);
     __block int time = 119;
     [self.GCDTimer event:^{
          if (time < 1) {
               //设置界面的按钮显示 根据自己需求设置
               [_yzmBtn setTitle:@"发送验证码" forState:UIControlStateNormal];
               _yzmBtn.userInteractionEnabled = YES;
               //            btn.backgroundColor = CYColor(79, 118, 245, 1);
               [weakself.GCDTimer destroy];
          } else {
               //        NSLog(@"time:%d", time);
               [_yzmBtn setTitle:[NSString stringWithFormat:@"%ds",time] forState:UIControlStateNormal];
               _yzmBtn.userInteractionEnabled = NO;
               //            btn.backgroundColor = CYColor(211, 211, 211, 1);
          }
          time--;
     } timeInterval:NSEC_PER_SEC * 1];
     [self.GCDTimer start];
}


//提现
-(void)tixianClick{
     
     
//     double amount = _accountTF.text.doubleValue;
//     DCPaymentView *payAlert = [[DCPaymentView alloc]init];
//     payAlert.detail = @"请输入交易密码";
//     payAlert.amount = amount;
//     
//     double yueaccount = _account.doubleValue;
//     if (amount>yueaccount) {
//          CYAlertView(@"您输入的金额有误");
//          return;
//     }
//     
//     [payAlert show];
//     payAlert.completeHandle = ^(NSString *inputPwd) {
//          NSString *str = [LEUUID UUIDForVendor];
//          NSString *desstr = [CYDES3Util encrypt:inputPwd];
//          CYUser *user = [CYLoginHttpTool userData].user;
//          [CYHttpTool postWithURL:[CYURL shared].withDrawCheckCode params:@{@"userId":user.userId,@"token":user.token,@"dealCode":desstr,@"amount":_accountTF.text,@"machineCode":str,@"phoneCode":_yzmTF.text} success:^(id json) {
//               CYLog(@"json = %@",json);
//               CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
//               if (jsonInfo.isSuccess) {
//                    [[NSNotificationCenter defaultCenter] postNotificationName:@"CYAssetAccountNotification" object:nil userInfo:nil];
//                    CYAlertView(jsonInfo.message);
//                    CYAlertView(@"到账时间：工作日6小时之内到账，节假日略有延迟");
//               }else {
//                    [MBProgressHUD showError:jsonInfo.message];
//                    CYAlertView(jsonInfo.message);
//               }
//          } failure:^(NSError *error) {
//               CYLog(@"error = %@",error);
//               CYAlertView(@"服务器连接失败");
//          }];
//          
//     };
}

-(void)viewbeclose{
     _weixinbg.hidden = YES;
     _weixinView.hidden = YES;
}


-(void)getIndexes:NSNotificationCenter {
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        [CYHttpTool postWithURL:[CYURL getAllPointByUserId] params:@{@"userId":user.userId} success:^(id json) {
            //            NSLog(@"——————————%@",json);
            self.user_point= json[@"message"];
            self.jifenLabel.text = [NSString stringWithFormat:@"%@积分",self.user_point];
            
        } failure:^(NSError *error) {
            CYLog(@"%@", error);
        }];
    }
}
/**
 *  加载余额
 */
- (void)loadBalance {
    _newyuelab.text = @"--";
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
         [CYHttpTool postWithURL:[CYURL shared].getUserAccountBalance params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
              CYJsonInfo *jsoninfo  = [CYJsonInfo objectWithKeyValues:json];
              CYLog(@"jsoninfo = %@",jsoninfo);
              NSDictionary *dic = jsoninfo.data;
              _account = [dic objectForKey:@"balance"];
              double yueacc = _account.doubleValue;
//              NSString *accountstr = _account.description;
              self.newyuelab.text = [NSString stringWithFormat:@"%.2f",yueacc];

              self.newyuelab.textAlignment = NSTextAlignmentLeft;
              
         } failure:^(NSError *error) {
              
         }];
    } else {
        self.newyuelab.text = @"---";
    }
}

//新版2点击事件

- (IBAction)zjmxClick:(id)sender {
     CYUser *user = [CYLoginHttpTool userData].user;
     if (user) {
          CYAssetDetailVC *ass = [[CYAssetDetailVC alloc]init];
          ass.hidesBottomBarWhenPushed = YES;
          [self.navigationController pushViewController:ass animated:YES];
     }else{
          [CYJumpsTool jumpToLogin:self];
     }

}

//提现
- (IBAction)txClick:(id)sender {
     
     
     
     CYUser *user = [CYLoginHttpTool userData].user;
     if (user) {
          CYTixianVC *tixian = [[CYTixianVC alloc]init];
          tixian.hidesBottomBarWhenPushed = YES;
          [self.navigationController pushViewController:tixian animated:YES];
          
          
     }else{
          [CYJumpsTool jumpToMain:self.view];
          
     }
     
//     UIView *bgView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//     bgView.backgroundColor = [UIColor grayColor];
//     bgView.alpha = 0.8;
//     self.weixinbg = bgView;
//     self.weixinbg.hidden = NO;
//     [[UIApplication sharedApplication].keyWindow addSubview:_weixinbg];
//     //     _shituview =[[UIView alloc]initWithFrame: CGRectMake(30,120,self.view.frame.size.width-60,400)];
//     _weixinView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.size.width-100, 300)];
//     _weixinView.layer.cornerRadius = 10.0f;
//     _weixinView.center = self.view.center;
//     _weixinView.backgroundColor = [UIColor whiteColor];
//     [[UIApplication sharedApplication].keyWindow addSubview:_weixinView];
//     [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_weixinView];
//     
//     //开始添加控件
//     UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
//     button.frame = CGRectMake(10, 10, 25, 25);
//     [button setImage:[UIImage imageNamed:@"icon_close_theme"] forState:UIControlStateNormal];
//     
//     [button addTarget:self action:@selector(viewbeclose) forControlEvents:UIControlEventTouchUpInside];
//     [_weixinView addSubview:button];
//     
//     UILabel *tixianlab = [[UILabel alloc]initWithFrame:CGRectMake(button.x+button.width+10, 10, self.weixinView.width-button.x-button.width-20, 20)];
//     tixianlab.text = @"提现申请";
//     tixianlab.textAlignment = NSTextAlignmentRight;
//     tixianlab.textColor = CYNaviThemeColor;
//     [_weixinView addSubview:tixianlab];
//     
//     _accountTF = [[UITextField alloc]initWithFrame:CGRectMake(button.x, button.y+button.height+20, self.weixinView.width-20, 40)];
//     _accountTF.delegate = self;
//     _accountTF.placeholder = @"请输入提现金额";
//     _accountTF.font = [UIFont systemFontOfSize:14.0f];
//     _accountTF.layer.cornerRadius = 3.0f;
//     _accountTF.layer.borderWidth = 1;
//     _accountTF.layer.borderColor = CYNaviThemeColor.CGColor;
//     [_weixinView addSubview:_accountTF];
//     
//     _yzmTF = [[UITextField alloc]initWithFrame:CGRectMake(button.x, _accountTF.y+_accountTF.height+10, _weixinView.width/2, 40)];
//     _yzmTF.delegate = self;
//     _yzmTF.placeholder = @"请输入短信验证码";
//     _yzmTF.font = [UIFont systemFontOfSize:14.0f];
//     _yzmTF.layer.cornerRadius = 3.0f;
//     _yzmTF.layer.borderWidth = 1;
//     _yzmTF.layer.borderColor = CYNaviThemeColor.CGColor;
//     [_weixinView addSubview:_yzmTF];
//     
//     UIButton *yzmbtn = [[UIButton alloc]initWithFrame:CGRectMake(_yzmTF.x+_yzmTF.width+5, _yzmTF.y, _weixinView.width-_yzmTF.x-_yzmTF.width-20, 40)];
//     
//     [yzmbtn setTitle:@"发送验证码" forState:UIControlStateNormal];
//     yzmbtn.titleLabel.font = [UIFont systemFontOfSize:14.0f];
//     yzmbtn.backgroundColor = CYNaviThemeColor;
//     [yzmbtn addTarget:self action:@selector(yzmClick) forControlEvents:UIControlEventTouchUpInside];
//     _yzmBtn = yzmbtn;
//     [_weixinView addSubview:_yzmBtn];
//     
//     UILabel *shouxuLab = [[UILabel alloc]initWithFrame:CGRectMake(button.x, _yzmTF.y+_yzmTF.height+10, self.weixinView.width-20, 20)];
//     shouxuLab.text = @"手续费:0.5%,单笔最低2元(第三方机构收取)";
//     shouxuLab.font = [UIFont systemFontOfSize:10.0f];
//     shouxuLab.textColor = [UIColor lightGrayColor];
//     [_weixinView addSubview:shouxuLab];
//     
//     UILabel *timelab = [[UILabel alloc]initWithFrame:CGRectMake(button.x, shouxuLab.height+shouxuLab.y+5, self.weixinView.width-20, 20)];
//     timelab.text = @"到账时间:工作日6小时之内到账,节假日略有延迟";
//     timelab.font = [UIFont systemFontOfSize:10.0f];
//     timelab.textColor = [UIColor lightGrayColor];
//     [_weixinView addSubview:timelab];
//     
//     
//     UIButton *tixianBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, timelab.height+timelab.y+20, _weixinView.width-40, 40)];
//     tixianBtn.layer.cornerRadius = 3.0f;
//     tixianBtn.backgroundColor = CYNaviThemeColor;
//     [tixianBtn setTitle:@"提现" forState:UIControlStateNormal];
//     [tixianBtn addTarget:self action:@selector(tixianClick) forControlEvents:UIControlEventTouchUpInside];
//     [_weixinView addSubview:tixianBtn];

     
}

//充值
- (IBAction)czClick:(id)sender {
     CYUser *user = [CYLoginHttpTool userData].user;
     //store版本备用 信用查询是否需要
     //     [CYHttpTool postWithURL:[CYURL shared].getCredit params:@{} success:^(id json) {
     //          CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
     //          NSString *str = jsoninfo.message;
     //          if (str.intValue == 1) {
     //               //不出充值功能
     //               CYAlertView(@"正在开发");
     //
     //          }else{
     //
     //
     //          }
     //
     //     } failure:^(NSError *error) {
     //          CYLog(@"error = %@",error);
     //     }];
     //恢复正常
     CYLog(@"show");
     //0为关
     CYLog(@"%@",_zhifubaoSwitch);
     if (user.certificateExamineStatus.intValue != 2) {
          CYAlertView(@"请先进行实名认证！");
          return;
     }
     if (_zhifubaoSwitch) {
          if (_zhifubaoSwitch.intValue == 0) {
               if (user) {
                    [UIInfomationView showAlertViewWithTitle:@"请输入充值金额" message:@"如您使用信用卡充值，第三方支付机构将收取1%的手续费" cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] style:UIAlertViewStylePlainTextInput keyboardType:UIKeyboardTypeNumberPad clickAtIndex:^(UIAlertView *alertView, NSInteger buttonIndex) {
                         if (buttonIndex == 1) {
                              UITextField *tf = [alertView textFieldAtIndex:0];
                              CYLog(@"tf: %@", tf.text);
                              CGFloat amount = tf.text.floatValue;
                              if (amount > 0 && amount<10001) {
                                   NSString *url = [CYURL shared].userRecharge;
                                   NSString *str = [LEUUID UUIDForVendor];
                                   LEWebViewController *web = [LEWebViewController createWebViewControllerWithURL:url param:@{@"userId": user.userId, @"token": user.token, @"account": tf.text , @"machineCode":str}];
                                   //设置滑动返回
                                   //                    self.navigationController.interactivePopGestureRecognizer.e1nabled = NO;
                                   web.hidesBottomBarWhenPushed = YES;
                                   [self.navigationController pushViewController:web animated:YES];
                                   
                              } else {
                                   [MBProgressHUD showError:@"单笔充值金额最大限额为10000.00"];
                              }
                         }
                    }];
               }else{
                    [CYJumpsTool jumpToLogin:self];
               }
               
          }else if (_zhifubaoSwitch.intValue == 1){
               //需要，弹窗选择
               if (user) {
                    UIAlertView *txaler = [[UIAlertView alloc]initWithTitle:@"请选择充值方式" message:@"防骗提示：“充值”功能为天下无赖所有收费的唯一官方途径，任何其他收费方式均是诈骗，请勿上当" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"银行卡",@"支付宝", nil];
                    [txaler show];
                    [txaler showAlertViewWithCompleteBlock:^(NSInteger buttonIndex) {
                         if (buttonIndex == 1) {
                              [UIInfomationView showAlertViewWithTitle:@"请输入充值金额" message:@"注：视银行不同，充值手续费为0-0.5%（信用卡充值，第三方支付机构将收取1%的手续费）" cancelButtonTitle:@"取消" otherButtonTitles:@[@"确定"] style:UIAlertViewStylePlainTextInput keyboardType:UIKeyboardTypeNumberPad clickAtIndex:^(UIAlertView *alertView, NSInteger buttonIndex) {
                                   if (buttonIndex == 1) {
                                        UITextField *tf = [alertView textFieldAtIndex:0];
                                        CYLog(@"tf: %@", tf.text);
                                        CGFloat amount = tf.text.floatValue;
                                        if (amount > 0 && amount<10001) {
                                             NSString *url = [CYURL shared].userRecharge;
                                             NSString *str = [LEUUID UUIDForVendor];
                                             LEWebViewController *web = [LEWebViewController createWebViewControllerWithURL:url param:@{@"userId": user.userId, @"token": user.token, @"account": tf.text , @"machineCode":str}];
                                             //设置滑动返回
                                             //  self.navigationController.interactivePopGestureRecognizer.e1nabled = NO;
                                             web.hidesBottomBarWhenPushed = YES;
                                             [self.navigationController pushViewController:web animated:YES];
                                             
                                        } else {
                                             [MBProgressHUD showError:@"单笔充值金额最大限额为10000.00"];
                                        }
                                   }
                              }];
                              
                         }if (buttonIndex == 2) {
                              
                              CYNewZFBVC *zvc = [[CYNewZFBVC alloc]init];
                              zvc.hidesBottomBarWhenPushed = YES;
                              [self.navigationController pushViewController:zvc animated:YES];
                              
                         }
                    }];
               }else{
                    [CYJumpsTool jumpToLogin:self];
               }
          }
          
     }else{
          CYAlertView(@"网络连接失败");
     }
}
//提升信用价值
- (IBAction)tsxysjClick:(id)sender {
      CYUser *user = [CYLoginHttpTool userData].user;
     
     if (user) {
          if (user.certificateExamineStatus.intValue != 2) {
               CYAlertView(@"请先进行实名认证！");
               return;
          }else{
               CYCreditNewLitmitVC *newlimit = [[CYCreditNewLitmitVC alloc]init];
               newlimit.hidesBottomBarWhenPushed = YES;
               [self.navigationController pushViewController:newlimit animated:YES];
          }
          
     }else{
          [CYJumpsTool jumpToLogin:self];
          
     }
     
     
}

//信用收益
- (IBAction)xysyClick:(id)sender {
     CYUser *user = [CYLoginHttpTool userData].user;
     if (user) {
          CYMoneyAddWebVC *add= [[CYMoneyAddWebVC alloc]init];
          add.hidesBottomBarWhenPushed = YES;
          [[self navigationController] setNavigationBarHidden:YES animated:YES];
          [self.navigationController pushViewController:add animated:YES];
     }else{
          [CYJumpsTool jumpToLogin:self];
     }
     
     
}

- (IBAction)zzfwClick:(id)sender {
     CYUser *user = [CYLoginHttpTool userData].user;
     if (user) {
          CYCreditAddWebVC *add= [[CYCreditAddWebVC alloc]init];
          add.hidesBottomBarWhenPushed = YES;
          [[self navigationController] setNavigationBarHidden:YES animated:YES];
          [self.navigationController pushViewController:add animated:YES];
     }else{
          [CYJumpsTool jumpToLogin:self];
     }
     
     
     
}


- (IBAction)cxlmClick:(id)sender {
     //信用查看
     CYUser *user = [CYLoginHttpTool userData].user;
     
     if (user) {
          if (user.certificateExamineStatus.intValue != 2) {
               CYAlertView(@"请先进行实名认证");
               return;
          }
          if (user.certificateExamineStatus.intValue == 2) {
               NSMutableDictionary *param = [NSMutableDictionary dictionary];
               if (user.phone) {
                    param[@"phone"] = user.phone;

               }else{
                    param[@"phone"] = @"";

               }
               if (user.name) {
                      param[@"name"] = user.name;
               }else{
                      param[@"name"] = @"";
               }
               if (user.certificateNo) {
                    param[@"condition"] = user.certificateNo;

               }else{
                    param[@"condition"] = @"";
 
               }
               if (param) {
                    CYUserCarFindWebVC *webvc = [[CYUserCarFindWebVC alloc] init];
                    webvc.param = param;
                    [[self navigationController]setNavigationBarHidden:YES animated:NO];
                    webvc.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:webvc animated:YES];
               }
               
     }
     }else{
          [CYJumpsTool jumpToLogin:self];
     }

     
}




/**
 *  积分中心
 */
- (IBAction)enter:(id)sender {
    CYUser *user = [CYLoginHttpTool userData].user;
    if(user){
        self.entershopbutton.titleLabel.text = @"";
        MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hud.mode=MBProgressHUDAnimationFade;//枚举类型不同的效果
        hud.labelText=@"加载中...";
        [CYMeHttpTool ShopwithaddressWithParams:@{@"userId": user.userId} success:^(NSString *message) {
            CreditWebViewController *shopwebVC = [[CreditWebViewController alloc] initWithUrl:message];
            shopwebVC.hidesBottomBarWhenPushed = YES;
            [MBProgressHUD hideHUDForView:self.view animated:YES];
            
            CYNavigationVController *navi = (CYNavigationVController *)self.navigationController;
            navi.bar.backgroundColor = CYNaviThemeColor;
            [navi pushViewController:shopwebVC animated:YES];
        } failure:^(NSError *error) {
            [MBProgressHUD hideHUDForView:self.view animated:YES];
            
        }];
    }
}
/**
 *  登陆判断按钮
 */
- (IBAction)loginBtnClick:(UIButton *)sender {
    CYUser *user = [CYLoginHttpTool userData].user;
    if (user) {
        CYPersonalDetailsVController *personDetail = [CYPersonalDetailsVController le_loadFromStoryBoard:self.storyboard];
        [self.navigationController pushViewController:personDetail animated:YES];
    } else {
        [CYJumpsTool jumpToLogin:self];
        if (self.loginBtn.hidden) {
            [self logout];
        }
    }
}
/**
 *  初始化个人中心数据
 */
- (void)loginStatus {
    //从沙盒中获取数据
    CYUser *user = [CYLoginHttpTool userData].user;
    //若数据不存在，表示用户未登录
    if (user) {
        self.personalBtn.enabled = YES;
//        self.personalBtn1.enabled = self.personalBtn.isEnabled;
        if (user.nickName) {
            self.mineDataLbel.text = user.nickName;
        }else {
            self.mineDataLbel.text = user.phone;
        }
        if (user.headPic && ![user.headPic isEqualToString:@""]) {
            //头像区边框
            [self setupHeadPicProperty];
             
            [self.personalBtn setImageWithURL:CYURLWithUserService(user.headPic) forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"complete_profile_men_sel"] size:CGSizeMake(200, 200)];
            
//            [self.personalBtn sd_setBackgroundImageWithURL:CYURLWithUserService(user.headPic) forState:UIControlStateNormal completed:nil];
        }
        self.loginBtn.hidden = YES;
        self.mineDataLbel.hidden = NO;
        self.iconPhotoImageView.hidden = NO;
    } else {
        self.personalBtn.enabled = NO;
//        self.personalBtn1.enabled = self.personalBtn.isEnabled;
        self.loginBtn.hidden = NO;
        self.mineDataLbel.hidden = YES;
        self.iconPhotoImageView.hidden = YES;
    }
}
/**
 *  设置头像边框
 */
- (void)setupHeadPicProperty {
    self.personalBtn.imageView.layer.cornerRadius = 30.0;
    self.personalBtn.imageView.layer.masksToBounds = YES;
    self.personalBtn.imageView.layer.borderColor = CYNaviThemeColorWithAlpha(.8).CGColor;
    self.personalBtn.imageView.layer.borderWidth = 2.5;
}
/**
 *  用户没有登录时跳转到登录界面
 */
- (IBAction)login:(id)sender {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
    UIViewController *loginViewController = storyboard.instantiateInitialViewController;
    [self presentViewController:loginViewController animated:YES completion:nil];
}
/**
 *  个人信息页面用户昵称更改监听方法
 */
- (void)nickNameChange:(NSNotification *)notification {
    NSString *nickName = notification.userInfo[CYChangedNickName];
    if (nickName) {
        self.mineDataLbel.text = nickName;
    }
    NSString *headPic = notification.userInfo[CYChangedHeadPic];
    if (headPic) {
        [self.personalBtn sd_setImageWithURL:CYURLWithUserService(headPic) forState:UIControlStateSelected placeholderImage:[UIImage imageWithName:@"match_randomPhoneDefaultHead"]];
        //头像区边框
        [self setupHeadPicProperty];
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
      [self loadBalance];
     CYUser *user = [CYLoginHttpTool userData].user;
    CYNavigationVController *navi = (CYNavigationVController *)self.navigationController;
    navi.bar.backgroundColor = [UIColor clearColor];
    [DSNavigationBar setNavigationBarWithNavigationBar:self.navigationController.navigationBar color:self.naviColor];
    if (user) {
        [self setbankcard];
        [self setdealcode];
        [CYHttpTool postWithURL:[CYURL shared].getExamineStatus params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
            CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
            NSDictionary *data = jsoninfo.data;
            if (data) {
                user.certificateExamineStatus = [data objectForKey:@"examineStatus"];
                user.name = [data objectForKey:@"name"];
                [CYLoginHttpTool updateUserData:user];
                if (user.certificateExamineStatus && ![user.certificateExamineStatus isKindOfClass:[NSNull class]]) {
                    if (user.certificateExamineStatus.intValue == 2) {
                        _statusLab.text = [NSString stringWithFormat:@"*%@ 已认证",[user.name substringFromIndex:1]];
                        _statusLab.textColor = [UIColor orangeColor];
                    }if (user.certificateExamineStatus.intValue == 1){
                        _statusLab.text = @"认证中";
                        _statusLab.textColor = [UIColor whiteColor];
                    }if (user.certificateExamineStatus.intValue == -1) {
                        _statusLab.text = @"未通过";
                        _statusLab.textColor = [UIColor redColor];
                    }if (user.certificateExamineStatus&&user.certificateExamineStatus.intValue == 0) {
                         _statusLab.text = @"未认证";
                         _statusLab.textColor = [UIColor whiteColor];
                    }
                }
                
            }
            
            if (!data) {
                _statusLab.text = @"去认证 ★";
                _statusLab.textColor = [UIColor whiteColor];
            }
        } failure:^(NSError *error) {
            
        }];
    }

}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [DSNavigationBar setNavigationBarWithNavigationBar:self.navigationController.navigationBar color:CYNaviThemeColor];
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    CYUser *user = [CYLoginHttpTool userData].user;
    //云同步
    if (indexPath.section ==0 && indexPath.row == 2) {
         
    } else if (indexPath.section == 0 && indexPath.row == 1){//我的消息
        if (user) {
            [JPUSHService setBadge:0];
            _pointImagView.hidden = YES;
            [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
            CYMessageViewController *MessageVC = [[CYMessageViewController alloc]init];
            MessageVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:MessageVC animated:YES];
        }
        else{
            [CYJumpsTool jumpToLogin:self];
        }
    }else if (indexPath.section == 2) {
        switch (indexPath.row) {
            case 0: {
                
                 
            }
                break;
                
            default:
                //分享
//                [self share];
                break;
        }
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0 &&indexPath.row ==0) {
        return 80;
    }
    return 50;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 4;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return .1;
}

- (void)hook_viewWillAppear:(BOOL)animated {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CYScreeSize.width, 64)];
    view.backgroundColor = CYNaviThemeColor;
    [self.view addSubview:view];
}
/**
 *  分享
 */
- (void)share {
    //调用快速分享接口  
     [UMSocialSnsService presentSnsIconSheetView:self appKey:UMAppkey shareText:@"天下无赖：信用贷款首选品牌！老赖信息查询预警，信用Bank快速低息借款，尽在天下无赖！www.credit-manage.com" shareImage:[UIImage imageNamed:@"40"] shareToSnsNames:nil delegate:self];
     [UMSocialSnsService handleOpenURL:[NSURL URLWithString:@"www.credit-manage.com"]];
     
     
//     [UMSocialSnsService presentUrlIconSheetView:self appKey:UMAppkey shareText:@"天下无赖：信用贷款首选品牌！老赖信息查询预警，信用Bank快速低息借款，尽在天下无赖！" shareImage:[UIImage imageNamed:@"40"] shareToSnsNames:nil shareUrl:@"www.credit-manage.com" delegate:self];
     
     
}


-(void)didCloseUIViewController:(UMSViewControllerType)fromViewControllerType {
//    [CYABTool jfshopWithType:@"3" success:^(NSString *message) {
//        
//    } failure:^(NSError *error) {
//        
//    }];
}
/**
 *  分享完成回调
 */
- (void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response {
    if (response.responseCode == UMSResponseCodeSuccess) {
        [CYABTool jfshopWithType:@"3" success:^(NSString *message) {
//            [LEMDLib showLongToaskWithMessgage:@"分享成功，获得2积分"];
        } failure:^(NSError *error) {
            
        }];
    }
}

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat scrollOffsetY = CYHeadViewHeight - scrollView.contentOffset.y;
    CGFloat constant = (CYHeadViewHeight - scrollOffsetY)/2.f;
    
    if (scrollOffsetY > CYHeadViewHeight) {//下拉
        self.imageTopConstraint.constant = CYHeadViewHeight - scrollOffsetY;
    } else if (constant < 80) {
        if (IOS8) {
            self.imageTopConstraint.constant = constant;
            self.imageBottomConstraint.constant = -constant;
        }
    }
    
    //    if (scrollView.contentOffset.y > 200 - 64) {
    //        self.naviColor = CYNaviThemeColorWithAlpha(1.f);
    //    } else {
    //        self.naviColor = CYNaviThemeColorWithAlpha(.0);
    //    }
    CGFloat alpha = scrollView.contentOffset.y/CYSectionTopToNaviBottomHeight;
    if (alpha < 0) {
        alpha = .0;
    } else if (alpha > 0.996) {
        alpha = 0.996;
    }
    self.naviColor = CYNaviThemeColorWithAlpha(alpha);
    [DSNavigationBar setNavigationBarWithNavigationBar:self.navigationController.navigationBar color:self.naviColor];
}

#pragma mark - 通知
- (void)setupNoti {
    [CYNotificationCenter addObserver:self selector:@selector(logoutNoti:) name:nCYLogout object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cardbandclick)name:CYCardBandNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dealcodeclick)name:CYDealCodeNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(assetaccountclick)name:CYAssetAccountNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushclick)name:CYPushNotification object:nil];
    
}
-(void)assetaccountclick{
     CYUser *user = [CYLoginHttpTool userData].user;
     if (user) {
          [CYHttpTool postWithURL:[CYURL shared].getUserAccountBalance params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
               CYJsonInfo *jsoninfo  = [CYJsonInfo objectWithKeyValues:json];
               CYLog(@"jsoninfo = %@",jsoninfo);
               NSDictionary *dic = jsoninfo.data;
               _account = [dic objectForKey:@"balance"];
               NSString *accountstr = _account.description;
               self.newyuelab.text = accountstr;
               self.newyuelab.textAlignment = NSTextAlignmentLeft;
               
          } failure:^(NSError *error) {
               
          }];
     } else {
          self.newyuelab.text = @"---";
     }

}

-(void)pushclick{
    _pointImagView.hidden = NO;
}

- (void)dealcodeclick{
    CYUser *user = [CYLoginHttpTool userData].user;
    [CYHttpTool postWithURL:[CYURL shared].getDealCodeStatus params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
        CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
        NSString  *type = jsonInfo.data;
        if (type.intValue == 1) {
            _dealcodelab.text = @"已设置";
        }else{
            _dealcodelab.text = @"未设置";
        }
    } failure:^(NSError *error) {
        CYLog(@"error = %@",error);
        _dealcodelab.text = @"--";
    }];
    
}
- (void)cardbandclick{
    CYUser *user = [CYLoginHttpTool userData].user;
    [CYHttpTool postWithURL:[CYURL shared].getBandCardStatus params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
        CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
        if (jsoninfo.isSuccess) {
            NSDictionary *data = jsoninfo.data;
            NSString *str = [data valueForKey:@"cardNo"];
            _bankcardlab.text = str;
            if (!_bankcardlab.text) {
                _bankcardlab.text = @"未绑定";
            }
        }
        
    } failure:^(NSError *error) {
        CYLog(@"error = %@",error);
    }];

    
}

- (void)logoutNoti:(NSNotification *)noti {
    [self logout];
}
/**
 *  登出后初始化显示数据
 */
- (void)logout {
    self.loginBtn.hidden = NO;
    self.mineDataLbel.hidden = YES;
    self.iconPhotoImageView.hidden = YES;
    [self.personalBtn setImage:[UIImage imageNamed:@"match_randomPhoneDefaultHead"] forState:UIControlStateNormal];
    self.newyuelab.text = @"--";
    self.jifenLabel.text = @"--";
    self.personalBtn.layer.borderColor = [UIColor clearColor].CGColor;
}



- (void)dealloc {
    //移除监听
    [CYNotificationCenter removeObserver:self];
    CYLog(@"个人中心销毁");
}

@end
